This README lists the R code, Stata code and data needed to replicate the figures and tables in the main text and supporting information of "Effects of Divisive Political Campaigns on the Day-to-Day Segregation of Arab and Muslim Americans".

Some data cannot be provided in raw form due to privacy concerns and other data-sharing issues. In those cases, we have provided the code needed to format and analyze the data.

Please contact the authors with any questions. We're happy to answer questions and we appreciate others double-checking the work.

File structure:
./code/
./data/
./figs/

CODE -- to produce results in paper

Main text:
plot_arabic_name_geotags.R
muslim_news.R
plot_news.R

SI:
analyze_arabic_sample_sources.R
analyze_survey.do

Pulling, formatting, sampling:
get_and_format_tweet_geo_args.py # format json
get_tweet_source_parallel.py # format json, + tweet source, text
create_arabic_sample_comparison_sampling_weights.R # matched sample sampling weights
arabic_sample_sources.R # matched sample analysis weights

DATA

Main text:
"arabic_usgeo_counts_20150901_to_20170213.RData"
"muslim_mentions_in_transcripts_coefs.RData"

SI:
"Muslim ban volume trend from 2015-03-07 to 2017-03-31.csv"
"transcript_count_muslim_mentions_by_date.RData"
"arabic_sample_only_usgeo_20150901_to_20170213_sources.RData"
    # note: voter data and voter derived weights not provided
"Dec 2016 table A8.dta"
"Feb 2017 tables A8-A9.dta"
"Feb 2017 tables a10-a12 fig a7.dta"
"June 2016 table A8.dta"

FIGURES

Main text

- Figure 1: Drop in geotags
    : plot_arabic_name_geotags.R

- Figure A1, A2: Words appearing with mention of “Muslim(s)” in news coverage
    : plot_news.R

- Figure A3: Comparison of Television News Coverage of Muslims and Twitter mentions of a Muslim ban
    : plot_arabic_name_geotags.R

- Figure A4: Drops in Arabic name, Arabic name and language, and Arabic name voter samples compared to a matched control group by source of tweet
    : analyze_arabic_sample_sources.R

- Figure A5: Other geotagged tweets (i.e. state-level geotags) by Arabic named Twitter users
    : plot_arabic_name_geotags.R

- Figure A6: drop in geotags after election
    : plot_arabic_name_geotags.R



TABLES
- Table 1, A1, A2: Words appearing with mention of “Muslim(s)” in news coverage
  : plot_news.R

- Table A1:
    : plot_wikipedia_views.R

- Table A3: demographics
    : arabic_sample_sources.R

- Table A4, A5: Change in geotagging in Arabic samples compared to control group
    : analyze_arabic_sample_sources.R

- Table A6, A7: Arabic geotagging text
    : arabic_sample_text.R

- Tables A8-A12: survey
    : analyze_survey.do
